import React, { useEffect } from 'react';
import { Link } from 'react-router-dom'
import { useSelector, useDispatch } from 'react-redux';
import { increment } from '../../store/actions/counterActions';

const Home = () => {
  const count = useSelector(state => state.counter.count);
  const dispatch = useDispatch();

  useEffect(() => {
    console.log('Home component mounted, count:', count);
  }, [count]);

  const handleClick = () => {
    console.log('Dispatching increment action');
    dispatch(increment());
  };

  return (
    <div>
      <h1>欢迎来到首页</h1>
      <p>这是一个使用 React 和 SSR 的示例应用。</p>
      <Link to={'/list'}>jump to list</Link>
      <p>点击次数: {count}</p>
      <button onClick={handleClick}>点击我</button>
    </div>
  );
};

export default Home;
